package com.operation.controller;

import com.operation.beans.Result;
import com.operation.beans.TimeAndPeople;
import com.operation.entity.HandleInfo;
import com.operation.entity.WorkOrder;
import com.operation.service.OperationService;
import com.operation.service.WorkOrderService;
import com.operation.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OperationServiceController {
    @Autowired
    OperationService operationService;
    @Autowired
    WorkOrderService workOrderService;

    /**
     * 运维人员接单
     * @param workOrder
     * @return
     */
    @RequestMapping(value = "/receiveWorkOrder",method = RequestMethod.POST)
    public Result receiveWorkOrder(@RequestBody WorkOrder workOrder){
        return operationService.receiveWorkOrder(workOrder);
    }

    /**
     * 运维人员甩单
     * @param handleInfo
     * @return
     */
    @RequestMapping(value = "/throwWorkOrder",method = RequestMethod.POST)
    public Result throwWorkOrder(@RequestBody HandleInfo handleInfo){
        return operationService.throwWorkOrder(handleInfo);
    }

    /**
     * 运维人员查看自己的任务
     * status为1时表示已完成 0表示未完成
     * @param handleInfo
     */
    @RequestMapping(value = "/isOngoingTasks",method = RequestMethod.POST)
    public Result isOngoingTasks(@RequestBody HandleInfo handleInfo){
        return operationService.IsOngoingTasks(handleInfo);
    }

    /**
     * 运维查看自己所有的单
     * @param receiveOne
     */
    @RequestMapping(value = "/queryMyAllWorkOrder/{receiveOne}",method = RequestMethod.GET)
    public Result queryMyAllWorkOrder(@PathVariable Integer receiveOne){
        return operationService.queryMyAllWorkOrder(receiveOne);
    }

    /**
     * 运维查看自己业绩
     * @param timeAndPeople
     */
    @RequestMapping(value = "/countWorkOrder",method = RequestMethod.POST)
    public Result queryMyAllWorkOrder(@RequestBody TimeAndPeople timeAndPeople){
        return operationService.countWorkOrder(timeAndPeople);
    }

    /**
     * 查看运维的星级和投诉
     * @return
     */
    @RequestMapping(value = "/countComplaintAndStar",method = RequestMethod.GET)
    public Result countComplaintAndStar(){
        return ResultUtil.success(workOrderService.findComplaintAndStar(),0);
    }

    /**
     * 运维查看自己未完成
     */
    @RequestMapping(value = "/isOnGoingWorkOrder/{receiveOne}",method = RequestMethod.GET)
    public Result isOnGoingWorkOrder(@PathVariable Integer receiveOne){
        return ResultUtil.success(operationService.isOnGoingWorkOrder(receiveOne),0);
    }
}
